package com.goldsprite.gdxcore.entities;

import com.badlogic.gdx.graphics.g2d.TextureRegion;

//自定义动画类
public class Animation {
	private final TextureRegion[] frames;
	private final float frameDuration;

	public Animation(TextureRegion[] frames, float frameDuration) {
		this.frames = frames;
		this.frameDuration = frameDuration;
	}

	//从播放时间获取当前帧
	public TextureRegion getFrame(float stateTime) {
		int frameIndex = (int) (stateTime / frameDuration) % frames.length;
		return frames[frameIndex];
	}
}
